﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections.Specialized;

namespace JiraConnector
{
    public partial class Settings : Form
    {
        public Settings()
        {
            InitializeComponent();

            this.txtPassword.Text = Properties.Settings.Default.JIRA_Password;
            this.txtUsername.Text = Properties.Settings.Default.JIRA_Username;
            this.txtURL3.Text = Properties.Settings.Default.JIRA_URL;

        }

        private void btnTest_Click(object sender, EventArgs e)
        {
            try
            {
                JiraConnector.JIRAConnector.getJIRAIssues(Properties.Settings.Default.JIRA_Username,
                    Properties.Settings.Default.JIRA_Password,
                    Properties.Settings.Default.JIRA_URL);

                toolStripStatusLabel1.Text = "OK";
                this.btnTest.ForeColor = Color.Green;
            }
            catch (Exception ex)
            {
                toolStripStatusLabel1.Text = ex.Message;
                this.btnTest.ForeColor = Color.Red;
            }
        }
        public String JIRA_Username()
        {
            return Properties.Settings.Default.JIRA_Username;
        }
        public String JIRA_Password()
        {
            return Properties.Settings.Default.JIRA_Password;
        }
        public String JIRA_URL()
        {
            return Properties.Settings.Default.JIRA_URL;
        }



        private void Settings_Load(object sender, EventArgs e)
        {

        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                Properties.Settings.Default.JIRA_Username = txtUsername.Text;
                Properties.Settings.Default.JIRA_Password = txtPassword.Text;
                Properties.Settings.Default.JIRA_URL = txtURL3.Text;
                Properties.Settings.Default.Save();
                toolStripStatusLabel1.Text = "DONE";
                this.btnSave.ForeColor = Color.Green;
            }
            catch (Exception ex)
            {
                toolStripStatusLabel1.Text = ex.Message;
                this.btnSave.ForeColor = Color.Red;
            }
        }
    }
}
